<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="referrer" content="no-referrer" />
    <title>OA系统</title>
    <link rel="stylesheet" href="/resources/layui/css/layui.css">
    <style>
        body{
            background: #f2f2f2;
        }
        .oa-container{
            background: white;
            position: absolute;
            width: 400px;
            height: 350px;
            top: 50%;
            left: 50%;
            padding: 20px;
            margin-left: -200px;
            margin-top: -175px;
        }
        #username,#password{
            text-align: center;
            font-size: 20px;
        }
    </style>
</head>
<body>
<div class="oa-container">
    <h1 style="text-align: center;margin-bottom: 20px">图书管理系统</h1>
    <form class="layui-form">
        <div class="layui-form-item">
        <input type="text" id="username" lay-verify="required" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-item">
            <input type="text" id="password" lay-verify="required" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-item">
            <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login">登录</button>
        </div>
    </form>
</div>
<script src="/resources/layui/layui.all.js"></script>
<script>
    layui.form.on("submit(login)",function (formdata) {
        console.log(formdata);
        layui.$.ajax({
            url : "/management/user/check_login",
            data : formdata.field,
            type : "post",
            dataType : "json",
            success : function (json) {
                console.log(json);
                if (json.code=="0"){
                    //layui.layer.msg("登陆成功");
                    window.location.href=json.redirect_url;

                }else{
                    layui.layer.msg(json.message);
                }
            }
        })
        return false;
    })
</script>
</body>
</html>